﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;

/// <summary>
/// 存储宇宙坐标位置
/// </summary>
public class PositionBase
{

    public PositionBase(){
        mInfinite_Distance = new List<int>();
    }

    private List<int> mInfinite_Distance;

    private int mYlyValue = 0;//单位亿光年，最大值亿亿光年

    private int mLightYearValue = 0;//光年距离值，最大数值。10000000，一亿

    private int mAuValue = 0;//天文距离单位10万au=1光年

    private int mKilometerValue = 0;//千米，1亿千米=1au天文单位 游戏中一个单位格子=10000km 

    public void AddInfinteData(int data,int index=0)
    {

        if (mInfinite_Distance.Count <= index)
        {
            mInfinite_Distance.Add(0);
        }
        mInfinite_Distance[mInfinite_Distance.Count - 1] += data;

        if (mInfinite_Distance[mInfinite_Distance.Count-1]>=GlobalVariable.CommonToY)
        {
            AddInfinteData((int)(mInfinite_Distance[mInfinite_Distance.Count - 1]/ GlobalVariable.CommonToY), mInfinite_Distance.Count);
        }
       
    }

    public int YlyValue
    {
        get
        {
            return mYlyValue;
        }

        set
        {
            mYlyValue = value;
        }
    }

    public int LightYearValue
    {
        get
        {
            return mLightYearValue;
        }

        set
        {
            mLightYearValue = value;
            if (mLightYearValue>=GlobalVariable.LyToYLy)
            {
                YlyValue += mLightYearValue / GlobalVariable.LyToYLy;
                mLightYearValue= mLightYearValue % GlobalVariable.LyToYLy;
            }
        }
    }

    public int AuValue
    {
        get
        {
            return mAuValue;
        }

        set
        {
            mAuValue = value;
            if (mAuValue>=GlobalVariable.AuToLy)
            {
                LightYearValue += (int)(mAuValue/ GlobalVariable.AuToLy);
                mAuValue = mAuValue % GlobalVariable.AuToLy;
            }
        }
    }

    public int KilometerValue
    {
        get
        {
            return mKilometerValue;
        }

        set
        {
            mKilometerValue = value;
            if (mKilometerValue>=GlobalVariable.KmToAu)
            {
                AuValue += (int)(mKilometerValue / GlobalVariable.KmToAu);
                mKilometerValue = mKilometerValue % GlobalVariable.KmToAu;
            }
        }
    }

    public List<int> Infinite_Distance
    {
        get
        {
            return mInfinite_Distance;
        }
    }
}
